package cn.mw.cmdb.param;

import cn.hutool.core.collection.CollUtil;
import cn.mw.cmdb.entity.InventoryWorkInfo;
import cn.mw.cmdb.service.ServiceChoose;
import cn.mw.cmdb.service.impl.InventoryWorkAssetsServiceImpl;
import cn.mw.cmdb.util.CMDBTool;
import cn.mw.components.mongodb.entity.CriteriaOpsType;
import cn.mw.components.mongodb.entity.SearchParam;
import cn.mw.components.mongodb.entity.SubCondition;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @Author shenwenyi
 * @Date 2024/6/22 23:05
 * @PackageName:cn.mw.cmdb.param
 * @ClassName: InventoryAssetsIdsParam
 * @Description: TODD
 * @Version 1.0
 */
@Data
public class InventoryAssetsIdsParam extends SearchParam implements ServiceChoose,SearchParamConvert{
    @Schema(description = "选择的Id集合")
    public List<String> ids;
    @Override
    public String getServiceId() {
        return InventoryWorkAssetsServiceImpl.ID;
    }

    @Override
    public void convert() throws Exception {
        //盘点任务名称
        List<String> ids = getIds();
        if (CollUtil.isNotEmpty(ids)) {
            this.addSubCondition(CMDBTool.getFieldName(InventoryWorkInfo::getId)
                    , new SubCondition(CriteriaOpsType.in.name(), ids));
        }
    }
}
